import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {PageHelper} from "../../../../utils/page-helper-model";
import {UserService} from "../../../../service/user.service";

@Component({
  selector: 'app-staff-dimission-list',
  templateUrl: './staff-dimission-list.component.html',
  styleUrls: ['./staff-dimission-list.component.less']
})
export class StaffDimissionListComponent implements OnInit {
  @Input()
  dimissionIsVisible : boolean;

  @Output()
  emit : EventEmitter<any> = new EventEmitter();

  pageHelper: PageHelper = new PageHelper;
  @Input()
  dimissionUserList : any;
  @Input()
  userInfo : any;
  @Output()
  dimissionLoad :  EventEmitter<any> = new EventEmitter();
  constructor(private userService: UserService,) {

  }

  ngOnInit(): void {
  }



  nzPageIndexChange(event: number) {
    this.pageHelper.numPages = event;
    this.dimissionLoad.emit();
  }
  delete(userId) {
    this.userService.layer.modalDeleteConfirm('确定要将该员工删除吗？', confirm => {
      if (confirm) {
        this.userService.deleteUserAndUserRole(userId,this.userInfo.roleId ,data => {
          if(data.isSuccess){
            this.userService.layer.messageSuccess("删除成功");
            setTimeout(()=>{this.dimissionLoad.emit();},500);
          }else{
            this.userService.layer.messageError(data.msg);
          }
        });
      }
    });
  }
  handleCancel(){
    this.emit.emit(false);
  }

  handleOk(){
    console.log("确定")
  }
}
